<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category   design_default
 * @package    Mage
 * @copyright  Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
 * @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
?>
<?php
/**
 * Product list template
 *
 * @see Mage_Catalog_Block_Product_List
 */
?>

<div class="block block-bestselling">
<div class="block-title">
	<h2><span><?php echo $this->__('Bestsellers')?></span></h2>
</div>
<div class="block-content">
<?php 
 $_products=$this->getProductCollection();
?>
		<?php if(count($_products) == 0)://if($_products->getSize()==0): ?>
				<div class="note-msg">
				<?php echo $this->__('No products sold yet. Products will be listed here after purchases are made...') ?>
				</div>
	    <?php else: ?>
				
				<?php $_collectionSize = $_products->getSize(); echo $_collectionSize; ?>
				<?php $sameProduct = array(); $count = 0; ?>
				<?php  foreach ($_products  as $_product): ?>			
				
                <?php $categoryIds = $_product->getData('category_ids'); ?>
				<?php $categoryIds = explode(',',$categoryIds);?>                
                <?php $categoryId  = $categoryIds[count($categoryIds)-1]; ?>
                <?php $category    = Mage::getModel('catalog/category')->load($categoryId);?>
				<div class="best-sell">
					<a class="product-image" href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>">
					<img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(125); ?>" width="125" height="125" alt="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>" title="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>" /></a>
					
					 <div class="product-shop">
					 <h3 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>"><?php echo $this->htmlEscape($_product->getName())?></a></h3> <?php //echo "<pre>"; print_r($_product->getData()); exit; ?>
					
					
					<?php echo $this->getPriceHtml($_product, true) ?>
					<!--<p><?php //echo $this->__('see all:')?><a href="<?php ///echo $category->getUrl(); ?>"> <?php //echo $category->getName(); ?></a></p>-->
					</div>
					<div class="clearer"></div>
					
				</div>
				<?php endforeach ?>
<?php endif; ?>
<div class="clearer"></div>

</div>
</div>

